package org.example.config;

import org.example.util.Md5Util;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 自定义Md5加密类
 */
public class CustomMd5PasswordEncoder implements PasswordEncoder {
	@Override
	public String encode(CharSequence rawPassword) {
		String encodePassword = Md5Util.hash(rawPassword.toString());
		return encodePassword;
	}

	@Override
	public boolean matches(CharSequence rawPassword, String encodedPassword) {
		return encode(rawPassword).equals(encodedPassword);
	}
}
